<?php if(!defined('ARCH_ROOT_PATH')) exit;
/**
 *	Architect Framework
 *
 *	Architect Framework is a light weight object oriented web applications framework written for PHP 5.1.4 and later that provide the tools to develop and deploy a website or application fast and with as little code as possible.
 *
 *	@author Robin Grass, <hello@coffinboy.se>
 *	@link http://architect.kodlabbet.net
 *	@license http://www.opensource.org/licenses/gpl-3.0.html GNU General Public License (v. 3)
 */

/**
 *	Architect_TemplateStream
 *
 *	This class holds simple template logic.
 *
 *	@package Streams
 *	@version 1.0
 *	@author Robin Grass, <hello@coffinboy.se>
 */
class Architect_TemplateStream extends Architect_StreamAbstract {

	/**
	 *	stream_open
	 *
	 *	This method
	 *
	 *	@param string $path
	 *	@param string $mode
	 *	@param int $options
	 *	@param string $opened_path
	 *
	 *	@return bool
	 */
	public function stream_open($path, $mode, $options, $opened_path) {
		$path = str_replace('tpl://', '', $path);
		$this->data = file_get_contents($path);
		$this->stat = stat($path);
		
		if($this->data === false)
			return false;
		
		if(!ini_get('short_open_tag')) {
			$this->data = str_replace(array('<?=', '?>'), array('<?php echo', '?>'), $this->data);
			$this->data = str_replace(array('<?', '?>'), array('<?php ', '?>'), $this->data);
		}
		
		$this->data = str_replace('$tpl->', '$this->', $this->data);
	
	return true;
	}

}
?>